#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import configparser


class Mysql(object):
    __instrace = None           # 通过判断类属性的方法来重复调用一个名称空间地址

    def __init__(self, host, port):
        self.host = host
        self.port = port

    @classmethod
    def from_conf(cls):
        if cls.__instrace is None:
            conf = configparser.ConfigParser()
            conf.read("configure.conf")
            cls.__instrace = Mysql(conf.get("mysql", "host"), conf.get("mysql", "port"))
        return cls.__instrace


sql1 = Mysql.from_conf()
sql2 = Mysql.from_conf()
sql3 = Mysql.from_conf()
print(sql1)
print(sql2)
print(sql3)
